﻿#region Usings

using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media;
using Microsoft.Surface.Presentation.Controls;
using ScrumTable.Common.Unity;
using ScrumTable.UI.ViewModel.Controller;
using ScrumTable.UI.ViewModel.Data;

#endregion

namespace ScrumTable.UI.View.WinTouch.UserControls.Menu.MenuItems
{

    /// <summary>
    /// Menu impl
    /// </summary>
    [ContentPropertyAttribute("Children")]
    public class Menu: IMenu
    {

        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------
      
        #endregion
        
        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        public MenuList Children { get; set; }
        public IMenu Parent { get; set; }
        public virtual bool CanClick { get { return true; } }

        public virtual string HomeButtonIconRessource
        {
            get { return "MenuIconHome"; }
        }

        public virtual NavigationTarget NavigatonTarget { get; set; }
        


        public ScrumController NaviController
        {
            get
            {
                return ((AppScreen)Application.Current.MainWindow).Container.Resolve<ScrumController>();
            }
        }

        public ScrumViewModelData ScrumData
        {
            get
            {
                return ((AppScreen)Application.Current.MainWindow).Container.Resolve<ScrumViewModelData>();
            }
        }

        public virtual string Text
        {
            get { return "Home"; }
        }
 

        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        public Menu()
        {
            Children = new MenuList(this);
        }

        public IMenu FindTarget(NavigationTarget target)
        {
            if (NavigatonTarget == target)
            {
                return this;
            }
            //search recursive
            return Children.Select(child => child.FindTarget(target)).FirstOrDefault(found => found != null);
         }

    
        
        
        #endregion




        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------


        public virtual void Action()
        {
            NaviController.GoTo(NavigationTarget.ScrumMap);
        }
      

        #endregion


        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------



        #endregion

    }
}
